const axios = require('axios')
const {imageSize}  = require('image-size')

const imageInfo = (imgUrl) => {
    return new Promise(async(resolve,reject)=>{
        try {
            const res =  await axios.get(imgUrl,{responseType:'arraybuffer'})
            const buffer = Buffer.from(res.data,'binary')
            const size = imageSize (buffer)
            resolve({
                width:size.width,
                height:size.height
            })
        } catch (error) {
            reject(error)
        }
    })
}

module.exports = imageInfo